A large number of important applications today are multi-threaded. Multi-threading allows the execution of a particular application or program to be divided into two or more separate threads. Each of these threads may then be executed in parallel on a multi-processor, or multi-core system. However, the use of multi-threading in multi-processor or multi-core settings increases the possibility and probability of concurrency errors. These errors typically fall into the categories of race conditions or atomicity violations. Given that many large applications and libraries may consist of hundreds or thousands of individual functions or methods, and a potential race condition or atomicity violation may occur when any combination of the functions or methods are executed simultaneously, these errors are among the most difficult type to detect by developers.
A race condition occurs when a shared variable is accessed by multiple threads without proper synchronization. Failure to detect a race condition may result in a deadlock or starvation. A deadlock may occur where two or more threads are holding resources that the other may need access to, but neither are willing or able to release them. Starvation is a similar problem where one or more threads are denied access to one or more resources by other threads.
An atomicity violation occurs if the results of a particular method depends on the concurrent execution of another method that operates on the same shared data. Atomicity violations may thread occur even if access to shared data is ordered through synchronization, therefore many techniques for race condition detection may not able to find such errors.